﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CDSBDemandControl.Presenter;
using CDSBDemandControl.Model;
using System.Web.UI.HtmlControls;
using CDSBDemandControl.Configuration;

namespace CDSBDemandControl.View.Web.PaginasInternas
{
    public partial class Disponibilidade : System.Web.UI.Page, IDiscriminatorDemand
    {
        #region Fields

        private Presenter.DiscriminatorDemand Presenter;
        string COOKIE_NAME = "cmbTimes.Cookies";
        bool existeAlgumTeam;

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Cache.SetExpires(DateTime.Now.Subtract(new TimeSpan(24, 0, 0)));
            Response.Cache.SetCacheability(HttpCacheability.NoCache);


            if (this.Session["Presenter"] == null)
            {
                this.Presenter = new DiscriminatorDemand(this);
                this.Session["Presenter"] = this.Presenter;
            }
            else
            {
                this.Presenter = (Presenter.DiscriminatorDemand)this.Session["Presenter"];
                this.Presenter.ResetView(this);
            }

            if (!this.IsPostBack) ApresentarListaTimes();

            if (!this.IsPostBack) this.ListarDisponibilidade();
        }

        private void ListarDisponibilidade()
        {
            this.ExibirObservacao
                (
                string.Format("Alocação / Disponibilidade no período de {0} à {1}.",
                DateTime.Now.Date.ToShortDateString(),
                DateTime.Now.AddDays(System.DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month) - 1).Date.ToShortDateString())
                );
            this.Presenter.RetornaListaDisp();
        }

        private void ExibirObservacao(string obs)
        {
            this.LblObsOrdenacao.Text = obs;
            this.LblObsOrdenacao.Visible = this.LblObsOrdenacao.Text.Length > 0 ? true : false;
        }

        public void ExibirListaDisp(IEnumerable<DemandModel> list, IEnumerable<DeveloperModel> modelAusencias, List<DateTime> fer)
        {
            IEnumerable<DeveloperModel> Developers = from Developer in this.Presenter.Developers
                                                     where Developer.IsActive && Developer.Mission == Mission.Developer
                                                     orderby Developer.DeveloperTeam descending, Developer.DeveloperName
                                                     select Developer;

            // Exibe a data da última atualização
            (this.Master.FindControl("LblUltimoUpdate") as Label).Text = "Última atualização em: " + this.Presenter.DemandListLastUpdate.ToShortDateString() + " as " + this.Presenter.DemandListLastUpdate.ToShortTimeString();

            (this.Master.FindControl("txtTimeToCompare") as HtmlGenericControl).InnerHtml =
                this.Presenter.DemandListLastUpdate.Year + "," +
                (this.Presenter.DemandListLastUpdate.Month - 1) + "," +
                this.Presenter.DemandListLastUpdate.Day + "," +
                this.Presenter.DemandListLastUpdate.Hour + "," +
                this.Presenter.DemandListLastUpdate.Minute + "," +
                this.Presenter.DemandListLastUpdate.Second;

            string links = @"<a href='Disponibilidade.aspx' 
            style='text-decoration:none; padding:0 0 5px 0; font: italic 15px Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; text-align:right;'>Atual</a>" +
            "|" +
                            @"<a href='Disponibilidade.aspx?addDays=30' 
            style='text-decoration:none; padding:0 0 5px 0; font: italic 15px Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; text-align:right;'>+30</a>" +
            "|" +
                            @"<a href='Disponibilidade.aspx?addDays=60' 
            style='text-decoration:none; padding:0 0 5px 0; font: italic 15px Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; text-align:right;'>+60</a>" +
            "|" +
                            @"<a href='Disponibilidade.aspx?addDays=90' 
            style='text-decoration:none; padding:0 0 5px 0; font: italic 15px Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; text-align:right;'>+90</a>" +
            "|" +
                            @"<a href='Disponibilidade.aspx?addDays=120' 
            style='text-decoration:none; padding:0 0 5px 0; font: italic 15px Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; text-align:right;'>+120</a>";

            string Team =
                (from Developer in Developers
                 where string.IsNullOrEmpty(cmbTimes.SelectedValue) || Developer.DeveloperTeam == cmbTimes.SelectedValue
                 select Developer.DeveloperTeam).First();

            List<string> DevelopersTeam = new List<string>();

            DivToTable.Controls.Add(new LiteralControl(@"<div align='left' style='padding:0 0 5px 0; 
                                                          text-align: left; font: italic 15px Trebuchet MS, Verdana, Arial, Helvetica, sans-serif;'>" + Team + @"</div>
                                                         <div align='right'>" + links + "</div>"));

            foreach (DeveloperModel Developer in Developers)
            {
                if (string.IsNullOrEmpty(cmbTimes.SelectedValue) || Developer.DeveloperTeam == cmbTimes.SelectedValue)
                {
                    if (Developer.DeveloperTeam == Team)
                    {
                        DevelopersTeam.Add(Developer.DeveloperName);
                    }
                    else
                    {
                        this.GenerateDinamicControls(DevelopersTeam, list, modelAusencias, fer);
                        Team = Developer.DeveloperTeam;
                        DevelopersTeam.Clear();
                        DevelopersTeam.Add(Developer.DeveloperName);
                        DivToTable.Controls.Add(new LiteralControl("<br />"));
                        DivToTable.Controls.Add(new LiteralControl(@"<div align='left' style='padding:0 0 5px 0; text-align: left; 
                                                                 font: italic 15px Trebuchet MS, Verdana, Arial, Helvetica, sans-serif;'>" + Team + @"</div>
                                                                 <div align='right'>" + links + "</div>"));
                    }
                }
            }

            this.GenerateDinamicControls(DevelopersTeam, list, modelAusencias, fer);
            DivToTable.Controls.Add(new LiteralControl("<br />"));
        }

        private void GenerateDinamicControls(
            List<string> users, IEnumerable<DemandModel> list, IEnumerable<DeveloperModel> developers, List<DateTime> feriados)
        {
            DateTime dtGeral;

            if (Request.QueryString["addDays"] != null)
                dtGeral = DateTime.Now.AddDays(Convert.ToDouble(Request.QueryString["addDays"]));
            else
                dtGeral = DateTime.Now;

            int numberOfCols = System.DateTime.DaysInMonth(dtGeral.Year, dtGeral.Month);
            int numberOfRows = users.Count;

            Table tbl = new Table();
            TableRow r;
            TableCell c;

            tbl.Attributes.Add("cellspacing", "1");
            tbl.Attributes.Add("cellpadding", "2");
            tbl.Attributes.Add("width", "100%");
            tbl.Style.Add("background-color", "#999999");
            tbl.Style.Add("width", "100%");

            for (int rowIndex = 0; rowIndex <= numberOfRows; rowIndex++) //Para cada usuario
            {
                r = new TableRow();

                #region Escreve estrutura da linha

                if (rowIndex != 0)
                {
                    //Escreve a linha 
                    r.Style.Add("align", "left");
                    r.Style.Add("background-color", "#FFFFFF");
                    r.Style.Add("font-family", "Verdana");
                    r.Style.Add("font-size", "X-Small");
                }
                else
                {
                    //Escreve o cabeçalho
                    r.Attributes.Add("align", "center");
                    r.Style.Add("background-color", "#CFDFF9");
                    r.Style.Add("font-family", "Verdana");
                    r.Style.Add("font-size", "X-Small");
                    r.Style.Add("font-weight", "bold");
                }

                #endregion

                #region Para cada dia do mes para esse usuario

                for (int colIndex = 0; colIndex <= numberOfCols; colIndex++)
                {
                    c = new TableCell();

                    if (colIndex == 0)
                    {
                        #region Se for a coluna com nome do usuário

                        c.Style.Add("align", "left");
                        c.Style.Add("background-color", "#CFDFF9");
                        c.Style.Add("font-family", "Verdana");
                        c.Style.Add("font-size", "X-Small");
                        c.Style.Add("font-weight", "bold");

                        if (rowIndex != 0)
                        {
                            string userName = users[rowIndex - 1];
                            c.Controls.Add(new LiteralControl(userName.ShortenName()));
                        }
                        else
                        {
                            c.Style.Add("text-align", "left");
                            c.Controls.Add(new LiteralControl(""));
                        }

                        c.Width = 150;

                        r.Cells.Add(c);

                        #endregion
                    }
                    else
                    {
                        if (rowIndex == 0)
                        {
                            #region Se for a linha do cabeçalho

                            string x = dtGeral.AddDays(colIndex - 1).Day + "/" + dtGeral.AddDays(colIndex - 1).Month;
                            c.Controls.Add(new LiteralControl(x));
                            r.Cells.Add(c);

                            #endregion
                        }
                        else
                        {
                            List<int> TasksId = this.FindByUserAndDate(list, users[rowIndex - 1], dtGeral.AddDays(colIndex - 1));

                            #region Em Atraso

                            if (colIndex == 1)
                            {
                                string auxId = string.Empty;

                                bool HasAtrasos = Request.QueryString["addDays"] == null && list.ToList().FindAll(
                                    delegate(DemandModel md)
                                    {
                                        bool HasActivities = md.AssignedTo == users[rowIndex - 1];
                                        bool HasDelayed = md.EstimatedConclude.HasValue && md.EstimatedConclude.Value.Date < dtGeral.Date;

                                        if (HasActivities && HasDelayed)
                                        {
                                            if (!string.IsNullOrEmpty(auxId))
                                                auxId += "<br />";

                                            auxId += "<a title='" + this.FindByID(list, Int32.Parse(md.ID)) + "'>" + md.ID + "<br />Task<br />em<br />atraso!" + "</a>";
                                        }
                                        return (HasActivities && HasDelayed);

                                    }).Count != 0;

                                if (HasAtrasos)
                                {
                                    if (TasksId.Count == 0)
                                    {
                                        c.Style.Add("background-color", "yellow");
                                        c.Style.Add("color", "red");
                                        c.Style.Add("font-weight", "bold");
                                        c.Controls.Add(new LiteralControl(auxId));
                                    }
                                    else
                                        c.Controls.Add(new LiteralControl("<div style='color: red; font-weight: bold;'>" + auxId + "</div>"));
                                }
                            }

                            #endregion

                            string x = string.Empty;
                            TipoApresentacao tipoApresentacao = TipoApresentacao.Nenhum; // 1 para programada / 2 para as demais

                            foreach (int TaskId in TasksId)
                            {
                                if (!string.IsNullOrEmpty(x))
                                    x += "<br />";

                                string founded = this.FindByID(list, TaskId);
                                string[] foundedSplit = founded.Split('-');

                                DateTime collumndate = dtGeral.AddDays(colIndex - 1);

                                int limit = foundedSplit.Count() - 1;

                                DateTime dtInicio = System.DateTime.Parse(foundedSplit[limit - 2]);
                                DateTime dtFim = System.DateTime.Parse(foundedSplit[limit - 1]);

                                string aux = string.Empty;

                                if (collumndate.Date == dtInicio.Date)
                                    aux = "<span style='color:green'>&bull;</span>" + TaskId;

                                if (collumndate.Date == dtFim.Date)
                                    if (aux.Equals(string.Empty))
                                        aux = TaskId + "<span style='color:red'>&bull;</span>";
                                    else
                                        aux = aux + "<span style='color:red'>&bull;</span>";

                                if (collumndate.Date == dtInicio.Date || collumndate.Date == dtFim.Date)
                                    x += "<a title='" + founded + "'>" + aux + "</a>";
                                else
                                    x += "<a title='" + founded + "'>" + TaskId + "</a>";

                                #region Descobre o tipo de itens a serem exibidos

                                if (foundedSplit[limit - 4].Trim() == "Ativa") tipoApresentacao |= TipoApresentacao.Agendado;
                                if (foundedSplit[limit - 4].Trim() != "Ativa") tipoApresentacao |= TipoApresentacao.Outros;

                                #endregion

                            }

                            #region Seta o background da celula atual conforme o item

                            if (!string.IsNullOrEmpty(x))
                            {
                                if (tipoApresentacao == (TipoApresentacao.Agendado | TipoApresentacao.Outros))
                                {
                                    c.Style.Add("background-color", TasksId.Count == 1 ? "#F0C6A0" : "#DD7B22");
                                }
                                else if (tipoApresentacao == TipoApresentacao.Agendado)
                                {
                                    c.Style.Add("background-color", TasksId.Count == 1 ? "#7BC2FF" : "#0087FF");
                                }
                                else if (tipoApresentacao == TipoApresentacao.Outros)
                                {
                                    c.Style.Add("background-color", TasksId.Count == 1 ? "#FFFF00" : "#FFCC66");
                                }
                            }

                            #endregion

                            if ((
                                dtGeral.AddDays(colIndex - 1).DayOfWeek == DayOfWeek.Saturday ||
                                dtGeral.AddDays(colIndex - 1).DayOfWeek == DayOfWeek.Sunday) ||
                                feriados.Contains(dtGeral.AddDays(colIndex - 1).Date))
                            {
                                if (!feriados.Contains(dtGeral.AddDays(colIndex - 1).Date))
                                    c.Style.Add("background-color", "#CCCCCC");
                                else
                                {
                                    if (string.IsNullOrEmpty(x))
                                    {
                                        c.Style.Add("background-color", "#EFEFEF");
                                        c.Controls.Add(new LiteralControl("Feriado"));
                                    }
                                    else
                                    {
                                        c.Style.Add("background-color", "#EFEFEF");
                                        if (x.IndexOf("&bull;") == -1)
                                            c.Controls.Add(new LiteralControl("Feriado"));
                                        else
                                        {
                                            string stt = x.Substring(x.IndexOf("<span style='color:red'>&bull;</span>") - 5, 5);
                                            c.Controls.Add(new LiteralControl("<a title='Data Final da Task é feriado. Task: " + stt + "'>Feriado*</a>"));
                                        }
                                    }
                                }
                            }
                            else
                            {
                                c.Controls.Add(new LiteralControl(x));
                            }
                            r.Cells.Add(c);
                        }
                    }
                }

                #endregion

                tbl.Rows.Add(r);
            }

            foreach (TableRow row in tbl.Rows)
            {
                string colaborador = (row.Cells[0].Controls[0] as LiteralControl).Text;

                Ferias ferias = this.TemFerias(colaborador, developers);
                List<FolgaProgramada> folga = this.TemFolga(colaborador, developers);

                string defaultColor = "#33CC33";

                #region Feriado

                for (int i = row.Cells.Count - 1; i > 0; i--)
                {
                    if (row.Cells[i].Controls.Count > 0)
                    {
                        if ((string.IsNullOrEmpty((row.Cells[i].Controls[0] as LiteralControl).Text)
                            || (row.Cells[i].Controls[0] as LiteralControl).Text == "Feriado")
                            )
                        {
                            if ((row.Cells[i].Controls[0] as LiteralControl).Text != "Feriado")
                                row.Cells[i].Style.Add("background-color", defaultColor);
                            else
                                row.Cells[i].Style.Add("background-color", "#EFEFEF");
                        }
                        else
                        {
                            defaultColor = "#FF0000";
                        }
                    }

                    DateTime dt = new DateTime(dtGeral.AddDays(i - 1).Year, dtGeral.AddDays(i - 1).Month, dtGeral.AddDays(i - 1).Day);

                    #region Férias

                    if (ferias != null)
                    {
                        if (dt.Date >= ferias.dataInicio.Date && dt.Date <= ferias.dataFim)
                        {
                            if (row.Cells[i].Controls.Count > 0)
                            {
                                if (row.Cells[i].Style["background-color"] != "#EFEFEF")
                                {
                                    string currentText = (row.Cells[i].Controls[0] as LiteralControl).Text;

                                    if (string.IsNullOrEmpty(currentText))
                                    {
                                        row.Cells[i].Style.Add("background-color", "#FFFF00");
                                        (row.Cells[i].Controls[0] as LiteralControl).Text = "Indisp";
                                    }
                                    else
                                    {
                                        int startTitle = currentText.IndexOf("'");
                                        int endTitle = currentText.LastIndexOf("'");

                                        string post = currentText.Substring(0, startTitle) + currentText.Substring(endTitle + 1);

                                        string TaskId = post.Substring(post.IndexOf(">") + 1).Replace("</a>", "");

                                        if (!string.IsNullOrEmpty(currentText))
                                        {
                                            row.Cells[i].Style.Add("background-color", "yellow");
                                            row.Cells[i].Style.Add("color", "red");
                                            row.Cells[i].Style.Add("font-weight", "bold");

                                            (row.Cells[i].Controls[0] as LiteralControl).Text = @"
                                            <a title='Task Associada Para Desenvolvedor Indisponível " + TaskId + "'>Indisp*</a>";
                                        }
                                        else
                                        {
                                            row.Cells[i].Style.Add("background-color", "#FFFF00");
                                            (row.Cells[i].Controls[0] as LiteralControl).Text = "Indisp";
                                        }
                                    }
                                }
                            }
                        }
                    }

                    #endregion

                    #region Folga

                    if (folga != null)
                    {
                        bool folgaHoje = false;
                        string hourHoje = string.Empty;
                        foreach (FolgaProgramada f in folga)
                        {
                            if (f.data.Date == dt.Date)
                            {
                                folgaHoje = true;
                                hourHoje = f.hours;
                                break;
                            }
                        }

                        if (folgaHoje)
                        {
                            if (row.Cells[i].Controls.Count > 0)
                            {
                                string currentText = (row.Cells[i].Controls[0] as LiteralControl).Text;

                                if (string.IsNullOrEmpty(currentText))
                                {
                                    row.Cells[i].Style.Add("background-color", "#FFFF00");
                                    (row.Cells[i].Controls[0] as LiteralControl).Text = "Indisp|" + hourHoje;
                                }
                                else
                                {
                                    int startTitle = currentText.IndexOf("'");
                                    int endTitle = currentText.LastIndexOf("'");

                                    string post = currentText.Substring(0, startTitle) + currentText.Substring(endTitle + 1);

                                    string TaskId = post.Substring(post.IndexOf(">") + 1).Replace("</a>", "");

                                    if (!string.IsNullOrEmpty(currentText))
                                    {
                                        row.Cells[i].Style.Add("background-color", "yellow");
                                        row.Cells[i].Style.Add("color", "red");
                                        row.Cells[i].Style.Add("font-weight", "bold");

                                        (row.Cells[i].Controls[0] as LiteralControl).Text = @"
                                        <a title='Task Associada Para Desenvolvedor Indisponível " + TaskId + "'>Indisp|" + hourHoje + "</a>";
                                    }
                                    else
                                    {
                                        row.Cells[i].Style.Add("background-color", "#FFFF00");
                                        (row.Cells[i].Controls[0] as LiteralControl).Text = "Indisp|" + hourHoje;
                                    }
                                }
                            }
                        }
                    }
                    #endregion
                }

                #endregion
            }

            DivToTable.Controls.Add(tbl);
        }

        private List<FolgaProgramada> TemFolga(string colaborador, IEnumerable<DeveloperModel> developers)
        {
            List<FolgaProgramada> retorno = null;

            DeveloperModel colab = developers.ToList().Find(delegate(DeveloperModel dev)
            {
                return dev.DeveloperName == colaborador;
            }
            );

            if (colab != null)
            {
                colab.Dayof.ForEach(delegate(string strData)
                            {
                                if (retorno == null)
                                    retorno = new List<FolgaProgramada>();

                                retorno.Add(new FolgaProgramada() { data = DateTime.Parse(strData.Split('|')[0]), hours = strData.Split('|')[1] });
                            });
            }

            return retorno;

        }

        private Ferias TemFerias(string colaborador, IEnumerable<DeveloperModel> developers)
        {
            Ferias retorno = null;

            DeveloperModel colab = developers.ToList().Find(delegate(DeveloperModel dev)
            {
                return dev.DeveloperName == colaborador;
            }
            );

            if (colab != null)
            {
                if (colab.StartFreeDaysPaid.HasValue && colab.FinishFreeDaysPaid.HasValue)
                {
                    retorno = new Ferias() { dataInicio = colab.StartFreeDaysPaid.Value, dataFim = colab.FinishFreeDaysPaid.Value };
                }
            }

            return retorno;
        }

        private string FindByID(IEnumerable<DemandModel> lstWorkItems, int TaskId)
        {
            string retorno = string.Empty;

            DemandModel wItem = lstWorkItems.ToList().Find(
                delegate(DemandModel wItemInterno)
                {
                    return (wItemInterno.ID == TaskId.ToString());
                });

            retorno += wItem.WorkItemType;
            retorno += " - ";

            retorno += wItem.ID;
            retorno += " - ";

            retorno += ((CDSBDemandControl.Model.DemandModelBase)(wItem)).Project;
            retorno += " - ";

            retorno += wItem.Title;
            retorno += " - ";

            retorno += wItem.State;
            retorno += " - ";

            retorno += wItem.WorkItemType;
            retorno += " - ";

            retorno += wItem.EstimatedStart.HasValue ? wItem.EstimatedStart.Value.ToShortDateString() : string.Empty;
            retorno += " - ";

            retorno += wItem.EstimatedConclude.HasValue ? wItem.EstimatedConclude.Value.ToShortDateString() : string.Empty;
            retorno += " - ";

            retorno += "Simultânea: " + ((wItem.IsSimultaneous) ? "Sim" : "Não");

            return retorno;

        }

        private List<int> FindByUserAndDate(IEnumerable<DemandModel> lstWorkItems, string userName, DateTime CollumnDate)
        {
            List<int> retorno = new List<int>();

            lstWorkItems.ToList().FindAll(
                delegate(DemandModel wItem)
                {
                    if (wItem.AssignedTo == userName)
                    {
                        if (wItem.EstimatedStart <= new DateTime(CollumnDate.Year, CollumnDate.Month, CollumnDate.Day, 23, 59, 59))
                        {
                            if (wItem.EstimatedConclude >= new DateTime(CollumnDate.Year, CollumnDate.Month, CollumnDate.Day, 0, 0, 0))
                            {
                                retorno.Add(Int32.Parse(wItem.ID));
                            }
                        }
                    }

                    return false;

                }
                    );

            return retorno;
        }

        #region IDiscriminatorDemand Members

        void IDiscriminatorDemand.ExibirFila(IEnumerable<CDSBDemandControl.Model.DemandModel> demandModels)
        {
            throw new NotImplementedException();
        }

        void IDiscriminatorDemand.ExibirEsteira(IEnumerable<CDSBDemandControl.Model.DemandModel> demandModels)
        {
            throw new NotImplementedException();
        }

        void IDiscriminatorDemand.ExibirRanking(IEnumerable<CDSBDemandControl.Model.DeveloperModel> developers, IEnumerable<CDSBDemandControl.Model.DeveloperModel> leaders, IEnumerable<CDSBDemandControl.Model.DeveloperModel> focalpoints)
        {
            throw new NotImplementedException();
        }

        void IDiscriminatorDemand.ExibirScenariosAndTasks(List<CDSBDemandControl.Model.ScenarioModel> scenarios)
        {
            throw new NotImplementedException();
        }

        void IDiscriminatorDemand.ExibirAtrasos(IEnumerable<CDSBDemandControl.Model.DemandModel> PendingDemands, IEnumerable<CDSBDemandControl.Model.DemandModel> Concludeddemands)
        {
            throw new NotImplementedException();
        }

        void IDiscriminatorDemand.ExibirFaturamento(List<CDSBDemandControl.Model.BillingModel> billing, bool canSeeBilling)
        {
            throw new NotImplementedException();
        }

        void IDiscriminatorDemand.ExibirCodeReview(IEnumerable<CDSBDemandControl.Model.DemandModel> WorkItemsWithCodeReview, IEnumerable<CDSBDemandControl.Model.DemandModel> WorkItemsWithoutCodeReview)
        {
            throw new NotImplementedException();
        }

        void IDiscriminatorDemand.ExibirBugsdeProducao(IEnumerable<CDSBDemandControl.Model.DemandModel> demandModels)
        {
            throw new NotImplementedException();
        }

        void IDiscriminatorDemand.ExibirBugsdeProducaoUltimoMes(List<CDSBDemandControl.Model.DemandModel> BugList)
        {
            throw new NotImplementedException();
        }

        void IDiscriminatorDemand.ExibirFactoryWaitingList(List<CDSBDemandControl.Model.BillingModel> Billing, bool AllowsShow)
        {
            throw new NotImplementedException();
        }

        void IDiscriminatorDemand.ExibirAlocacao(IEnumerable<CDSBDemandControl.Model.DemandModel> demandModels)
        {
            throw new NotImplementedException();
        }

        void IDiscriminatorDemand.ExibirFactoryProductionList(List<BillingModel> billing, bool canSeeBilling)
        {
            throw new NotImplementedException();
        }

        void IDiscriminatorDemand.ExibirSolicitacoesSites(List<CDSBDemandControl.Model.DemandModel> demandModels)
        {
            throw new NotImplementedException();
        }

        void IDiscriminatorDemand.ExibirManagementTeamTasks(List<CDSBDemandControl.Model.DemandModel> demandModels)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region Cookies

        protected void cmbTimes_SelectedIndexChanged(object sender, EventArgs e)
        {
            CriaCookieTeam(cmbTimes.SelectedValue);
            this.ListarDisponibilidade();

        }

        public void ApresentarListaTimes()
        {
            var teams = (from Developer in this.Presenter.Developers
                         where Developer.IsActive && Developer.Mission == Mission.Developer
                         orderby Developer.DeveloperTeam descending
                         select Developer.DeveloperTeam).Distinct();

            cmbTimes.DataSource = teams;
            cmbTimes.DataBind();
            cmbTimes.Items.Insert(0, string.Empty);

            if (this.Request.Browser.Cookies)
            {
                HttpCookie cookie = this.Request.Cookies[COOKIE_NAME];
                if (cookie != null && cookie.Expires < DateTime.Now)
                {
                    cmbTimes.SelectedValue = cookie["teamName"];
                }
                else
                {
                    CriaCookieTeam(string.Empty);
                }
            }
        }

        public void CriaCookieTeam(string valor)
        {
            HttpCookie cookie;

            this.Response.Cookies.Add(cookie = new HttpCookie(COOKIE_NAME));
            cookie.Expires = DateTime.Now.AddYears(1);
            cookie["teamName"] = valor;
            cookie.Path = "/";
        }

        #endregion

        #region Nestled Types

        enum TipoApresentacao : byte
        {
            Nenhum = 0,
            Agendado = 1,
            Outros = 2
        }

        #endregion

    }
}

